package com.yanqu.road.logic.activity.foxcard.game.effect;

import com.yanqu.road.entity.activity.foxcard.FoxBaseCard;
import com.yanqu.road.entity.activity.foxcard.FoxHandCard;
import com.yanqu.road.logic.activity.foxcard.game.FoxCardCombo;
import com.yanqu.road.logic.activity.foxcard.game.FoxCardGameLogic;
import com.yanqu.road.logic.activity.foxcard.game.eFoxCardShowType;
import com.yanqu.road.logic.activity.foxcard.game.eFoxCardTriggerType;

import java.util.Collections;
import java.util.List;

/**
 * 整局挑战中，每打出一次对应的牌型，小丑牌提供的加成会增加。
 * params:牌型|加筹码基础值|乘筹码基础值|加倍率基础值|乘倍率基础值|金币基础值
 * upgradeParams:加筹码增幅值|乘筹码增幅值|加倍率增幅值|乘倍率增幅值|金币增幅值
 */
public class FoxCardEffect2 extends FoxCardEffectBase {
    @Override
    protected void effectHandle(FoxCardGameLogic gameLogic, FoxHandCard handCard) {
        Integer checkComboType = Integer.valueOf(effectConfig.getParamsList().get(0));
        if (triggerType == eFoxCardTriggerType.AFTER_SCORE) {
            int totalTimes = gameLogic.getHistoryComboShowTimes(checkComboType);

            int addBaseScore = Integer.valueOf(effectConfig.getParamsList().get(1)) + totalTimes * Integer.valueOf(effectConfig.getUpgradeParamsList().get(0));
            int addBaseScoreMulti = Integer.valueOf(effectConfig.getParamsList().get(2)) + totalTimes * Integer.valueOf(effectConfig.getUpgradeParamsList().get(1));
            int addBaseMulti = Integer.valueOf(effectConfig.getParamsList().get(3)) + totalTimes * Integer.valueOf(effectConfig.getUpgradeParamsList().get(2));
            int addBaseMultiMulti = Integer.valueOf(effectConfig.getParamsList().get(4)) + totalTimes * Integer.valueOf(effectConfig.getUpgradeParamsList().get(3));
            int goldChange = Integer.valueOf(effectConfig.getParamsList().get(5)) + totalTimes * Integer.valueOf(effectConfig.getUpgradeParamsList().get(4));

            List<FoxBaseCard> foxEffectCards = Collections.singletonList(effectCard);
            gameLogic.addBaseScore(addBaseScore, foxEffectCards, null); //加基础筹码
            gameLogic.addBaseScoreMulti(addBaseScoreMulti, foxEffectCards, null); //当前基础筹码乘算
            gameLogic.addBaseMulti(addBaseMulti, foxEffectCards, null); //加基础倍率
            gameLogic.addBaseMultiMulti(addBaseMultiMulti, foxEffectCards, null); //当前基础倍率乘算
            gameLogic.goldChange(goldChange, foxEffectCards, null, triggerType); //加金币
        } else if (triggerType == eFoxCardTriggerType.BEFORE_SCORE) {
            FoxCardCombo nowCombo = gameLogic.getNowCombo();
            if (nowCombo.getComboId() == checkComboType) {
                gameLogic.newFoxShow(eFoxCardShowType.EFFECT_CARD_LV_UP.getValue()).setSettleCards(Collections.singletonList(effectCard)).setShowValue(1);
            }
        }
    }
}
